<template>
	<view>
		<u-popup :customStyle="{'width':'90%'}" :show="infoPop" mode="center" round="20" :closeOnClickOverlay="true"
			@close="close" @open="open" :closeable="false" :safeAreaInsetBottom="false">
			<view class="bgfff mauto h100b ml30 mr30  zdex9 ius10">
				<view class="fz30 bold txtcen pt20 pb20 bged col00">我的信息</view>
				<view class="pl20 pr20 pb20 pt20 ">
					<view class="flex alicen">
						<view class="mr30">首选科目</view>
						<view class="flex mr20 alicen" v-for="(item,index) in sxkmList" :key="index"
							@tap="sxkmTab(item)">
							<image class="w30 h30"
								:src="model1.sxkm == item.name?cosImageUrl('check.png',true):cosImageUrl('nocheck.png',true)"
								mode="aspectFill"></image>
							<view class="fz28 ml10">{{item.name}}</view>
						</view>
					</view>
					<view class="flex alicen">
						<view class="mr30">再选科目</view>
						<view class="flex mr20 alicen" v-for="item in zxkmList" :key="item" @tap.stop="zxkmTab(item)">
							<image class="w30 h30"
								:src="arr1[0].includes(item)?cosImageUrl('check.png',true):cosImageUrl('nocheck.png',true)"
								mode="aspectFill"></image>
							<view class="fz28 ml10">{{item}}</view>
						</view>
					</view>
					<!--
					<view class="flex alicen mt20">
						<view class="fz24 nowrap mr20">请输入您的区内高校总分(含加分)</view>
						<view class="flex alicen border1 boree">
							<input type="number" v-model="model1.gxgrade" />
							<view class="fz24">分</view>
						</view>
					</view>
					-->
					<view class="pb30 bdr1_bottom boree"></view>
					<view class="flex alicen mt20">
						<view class="fz24 nowrap mr20">请输入您的高考总分（含加分）</view>
						<view class="flex alicen border1 boree">
							<input type="number" v-model="model1.qggrade" />
							<view class="fz24">分</view>
						</view>
					</view>
					<view class="pb30 bdr1_bottom boree"></view>
					<view class="flex alicen between mt20 pb20 bdr1_bottom boree">
						<view class="fz24 nowrap mr20">少数民族</view>
						<view class="flex">
							<view class="flex mr20  alicen" v-for="(item,index) in sfssmzList" :key="index"
								@tap.stop="sfssmzBtn(item.value)">
								<image class="w30 h30"
									:src="model1.sfssmz == item.value?cosImageUrl('check.png',true):cosImageUrl('nocheck.png',true)"
									mode="aspectFill"></image>
								<view class="fz28 ml10">{{item.name}}</view>
							</view>
						</view>

					</view>
					<view class="flex alicen between mt20 pb20 bdr1_bottom boree">
						<view class="fz24 nowrap mr20">符合国家专项计划</view>
						<view class="flex">
							<view class="flex mr20 alicen" v-for="(item,index) in sfdfzxList" :key="index"
								@tap.stop="sfdfzxBtn(item.value)">
								<image class="w30 h30"
									:src="model1.sfgjzxdfzx == item.value?cosImageUrl('check.png',true):cosImageUrl('nocheck.png',true)"
									mode="aspectFill"></image>
								<view class="fz28 ml10">{{item.name}}</view>
							</view>
						</view>
					</view>
					<view class="flex alicen between mt20 pb20 bdr1_bottom boree">
						<view class="fz24 nowrap mr20">符合地方专项计划</view>
						<view class="flex">
							<view class="flex mr20 alicen" v-for="(item,index) in sfdfzxList" :key="index"
								@tap.stop="sfdfzxBtn(item.value)">
								<image class="w30 h30"
									:src="model1.sfdfzx == item.value?cosImageUrl('check.png',true):cosImageUrl('nocheck.png',true)"
									mode="aspectFill"></image>
								<view class="fz28 ml10">{{item.name}}</view>
							</view>
						</view>
					</view>
					<view class="fz24 nowrap mr20 colff7e5f">以下信息非必填，可<text class="ml10 col0000ff"
						@click="navswitch('/pages/keFuservice/keFuservice')">联系客服</text> 获取优惠</view>
					<view class="flex between alicen mt20" v-if="model1.sfvip == 0">
						<view class="fz24 nowrap mr20">会员卡号</view>
						<view class="flex alicen bdr1_bottom boree">
							<input type="number" v-model="model1.cardNo"/>

						</view>
					</view>
					<view class="flex between alicen mt20"  v-if="model1.sfvip == 0">
						<view class="fz24 nowrap mr20">会员激活密码</view>
						<view class="flex alicen bdr1_bottom boree">
							<input type="safe-password" v-model="model1.cardPwd"/>
						</view>
					</view>
					<!-- <u-form-item prop="userInfo.kmTmp" borderBottom ref="item1" labelPosition="top">
						<u-row>
							<u-col span="3">
								<view class="txtcen">首选科目</view>
							</u-col>
							<u-col span="9">
								<u-radio-group v-model="model1.sxkm" placement="row" :disabled="isView">
									<u-radio shape="circle" :customStyle="{marginRight: '16px'}"
										v-for="(item, index) in sxkmList" :key="index" :label="item.name"
										:name="item.name"></u-radio>
								</u-radio-group>
							</u-col>
						</u-row>
						<u-row class="mt20">
							<u-col span="3">
								<view class="txtcen">再选科目</view>
							</u-col>
							<u-col span="9">
								<u-checkbox-group v-model="model1.zxkm" placement="row" :disabled="isView">
									<u-checkbox  activeColor="red" shape="circle" :customStyle="{marginRight: '16px'}"
										v-for="(item, index) in zxkmList" :key="index" :label="item.name"
										:name="item.name"></u-checkbox>
								</u-checkbox-group>
							</u-col>
						</u-row>
					</u-form-item> -->

					<!-- <u--form labelPosition="left" :model="model1" :rules="rules" ref="uForm" labelAlign="right"
						:labelStyle="{'font-size':'14px','color':'black'}" errorType="none">
						<u-form-item prop="userInfo.qggrade" borderBottom ref="item1">
							<view class="flex row alicen">
								<view class="nowrap fz28 colb6">请输入您的区内高考总分(含加分)</view>
								<view class="flex alicen ml10" style="border: 1rpx solid #ededed;">
									<u--input border="none" v-model="model1.grade" type="number" maxlength="3"
										:readonly="isView" clearable></u--input>
									<view style="padding: 0 1%;">分</view>
								</view>
							</view>
						</u-form-item>
						<u-form-item prop="userInfo.gxgrade" borderBottom ref="item1">
							<view class="flex row alicen">
								<view class="nowrap fz28 colb6">请输入您的区内高考总分(含加分)</view>
								<view class="flex alicen ml10" style="border: 1rpx solid #ededed;">
									<u--input border="none" v-model="model1.gxgrade" type="number" maxlength="3"
										:readonly="isView" clearable></u--input>
									<view style="padding: 0 1%;">分</view>
								</view>
							</view>
						</u-form-item>
						
								
						<u-form-item label="少数民族" prop="userInfo.sfssmz" borderBottom ref="item1" labelWidth='150'
							style="display:none">
							<u-radio-group v-model="model1.sfssmz" placement="row">
								<u-radio :customStyle="{marginRight: '16px'}" v-for="(item, index) in sfssmzList"
									:key="index" :label="item.name" :name="item.value">
								</u-radio>
							</u-radio-group>
						</u-form-item>
						<u-form-item label="符合国家专项计划" prop="userInfo.sfgjzxdfzx" borderBottom ref="item1" labelWidth='150'
							style="display:none">
							<u-radio-group v-model="model1.sfgjzxdfzx" placement="row">
								<u-radio :customStyle="{marginRight: '16px'}" v-for="(item, index) in sfssmzList"
									:key="index" :label="item.name" :name="item.value">
								</u-radio>
							</u-radio-group>
						</u-form-item>
					</u--form> -->
				</view>
				<view class="pb60"></view>
				<view class="pt20 pb20 ml20 mr20 mb20 ius100 pt20 pb20 colff flexCenter bgff000" @click="submitUser()">
					保存
				</view>
			</view>

		</u-popup>
	</view>
</template>
<script>
	export default {
		props: {
			infoPop: {
				type: Boolean,
				default: false,
			}
		},
		data() {
			return {
				model1: {},
				arr1: [],
				sxkmList: [{
						name: '历史',
					},
					{
						name: '物理',
					}
				],
				zxkmList: ['化学', '生物', '地理', '政治'],
				sfssmzList: [{
						name: '是',
						value: 1,
						disabled: false
					},
					{
						name: '否',
						value: 0,
						disabled: false
					}
				],
				sfdfzxList: [{
						name: '是',
						value: 1,
						disabled: false
					},
					{
						name: '否',
						value: 0,
						disabled: false
					}
				],

			}
		},
		created() {
			this.userInfo(); //用户信息
		},
		methods: {
			//首选科目事件
			sxkmTab(item) {
				if (item.name == this.model1.sxkm) return;
				this.model1.sxkm = item.name
			},
			//少数名族事件
			sfssmzBtn(value) {
				this.model1.sfssmz = value
			},
			sfdfzxBtn(value) {
				this.model1.sfdfzx = value
			},
			//再选科目事件
			zxkmTab(item) {
				if (!this.arr1[0] || !Array.isArray(this.arr1[0])) {
					this.arr1[0] = [];
				}
				let flag = this.arr1[0].includes(item);
				if (!flag) {
					this.arr1[0].push(item);
				} else {
					this.arr1[0] = this.arr1[0].filter(i => i !== item);
				}
				this.model1.zxkm = this.arr1[0].join(',');
			},
			async userInfo() {
				let params = {
					useId: this.readData('useId')
				}
				let users = await this.request.get('/api/loginMemberById', {
					params
				})
				if (users.code == 200) {
					console.log('news', users.data)
					this.model1 = users.data
					this.arr1.push(users.data.zxkm)
					console.log('arr1', this.arr1)
				}
			}, //用户信息
			async submitUser() {
				let params = {
					phone: this.model1?.phone,
					grade: this.model1?.qggrade,
					qggrade: this.model1?.qggrade,
					gxgrade: this.model1?.qggrade,
					sxkm: this.model1?.sxkm,
					zxkm: this.model1?.zxkm,
					sfssmz: this.model1?.sfssmz,
					sfgjzxdfzx: this.model1?.sfgjzxdfzx,
					sfdfzx: this.model1?.sfdfzx,
					cardNo: this.model1?.cardNo,
					cardPwd: this.model1?.cardPwd,
				}
				let updates = await this.request.get('/api/updateMember', {
					params
				})
				if (updates.code == 200) {
					console.log('news', updates.data)
					this.successToShow(updates.msg || '更新成功', call => {
						this.$emit('updates')
					})
				}
			},
			open() {

			},
			close() {
				this.$emit('updates')
			},
		},

	}
</script>
<style>

</style>